Skip to content

Composefs native refactor#1599

Merged
cgwalters merged 3 commits into
bootc-dev:composefs-backendfrom
Johan-Liebert1:composefs-native-refactor
Sep 9, 2025
Merged

Composefs native refactor#1599
cgwalters merged 3 commits into
bootc-dev:composefs-backendfrom
Johan-Liebert1:composefs-native-refactor

Conversation

@Johan-Liebert1

Copy link
Copy Markdown
Collaborator

Changes

Move all composefs-native related code to crates/lib/src/bootc_composefs. This might help us to spot diff while merging, also should hopefully create less conflicts on subsequent

Gate composefs-native behind composefs-backend flag

Refactor to use #[cfg(feature = "composefs-backend")] to gate composefs native features behind the flag.

Gate the following features

  • --composefs-native and its corresponding cli args
  • Installing/Switching/Upgrading/RollingBack of composefs native system
  • Create separate install, rollback functions for ostree for a bit cleaner of a setup

Move all composefs-native related stuff into `lib/src/bootc_composefs`.
This might help us to spot diff while merging into main, also should
hopefully create less conflicts

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Refactor to use `#[cfg(feature = "composefs-backend")]` to gate
composefs native features behind the flag.

Gate the following features
- `--composefs-native` and its corresponding cli args
- Installing/Switching/Upgrading/RollingBack of composefs native system
- Create separate install, rollback functions for ostree for a bit
  cleaner of a setup

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a significant and well-executed refactoring that moves all composefs-native related code into a dedicated crates/lib/src/bootc_composefs module and gates it behind a composefs-backend feature flag. The changes are clean and align with the stated goals. I've identified a high-severity bug in switch.rs where the transport protocol is hardcoded, which would prevent switching to images from non-docker registries. Additionally, I've found a couple of minor typos in error messages and suggested a small refactoring in repo.rs for improved efficiency and code clarity. Overall, great work on this refactoring.

Comment thread crates/lib/src/bootc_composefs/switch.rs Outdated
Comment on lines +71 to +86
let repo = open_composefs_repo(&rootfs_dir).context("Opening compoesfs repo")?;

let (id, verity) =
composefs_oci_pull(&Arc::new(repo), &format!("{transport}:{image}"), None, None)
.await
.context("Pulling composefs repo")?;

tracing::debug!(
"id = {id}, verity = {verity}",
id = hex::encode(id),
verity = verity.to_hex()
);

let repo = open_composefs_repo(&rootfs_dir)?;
let mut fs = create_composefs_filesystem(&repo, &hex::encode(id), None)
.context("Failed to create composefs filesystem")?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To avoid opening the composefs repository twice, you can create an Arc for the repository and reuse it. This is slightly more efficient and makes the code cleaner. This change also fixes a typo in the error message on line 71.

Suggested change
let repo = open_composefs_repo(&rootfs_dir).context("Opening compoesfs repo")?;
let (id, verity) =
composefs_oci_pull(&Arc::new(repo), &format!("{transport}:{image}"), None, None)
.await
.context("Pulling composefs repo")?;
tracing::debug!(
"id = {id}, verity = {verity}",
id = hex::encode(id),
verity = verity.to_hex()
);
let repo = open_composefs_repo(&rootfs_dir)?;
let mut fs = create_composefs_filesystem(&repo, &hex::encode(id), None)
.context("Failed to create composefs filesystem")?;
let repo = Arc::new(open_composefs_repo(&rootfs_dir).context("Opening composefs repo")?);
let (id, verity) =
composefs_oci_pull(&repo, &format!("{transport}:{image}"), None, None)
.await
.context("Pulling composefs repo")?;
tracing::debug!(
"id = {id}, verity = {verity}",
id = hex::encode(id),
verity = verity.to_hex()
);
let mut fs = create_composefs_filesystem(&repo, &hex::encode(id), None)
.context("Failed to create composefs filesystem")?;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We return the repo right now and most functions accept a non Arc repo

Comment thread crates/lib/src/bootc_composefs/state.rs Outdated
Fix typo in error message
Unhardcode transport while pulling a composefs repository on
switch

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
@travier

travier commented Sep 9, 2025

Copy link
Copy Markdown
Contributor

Might be worth opening the same PR but against main directly if we think we are ready to merge this gated by a feature flag. Might be easier to read the diff.

@cgwalters cgwalters left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm tentatively OK as is but there's a lot of followup here

Comment thread crates/lib/src/cli.rs
Comment on lines +1316 to +1324
#[cfg(feature = "composefs-backend")]
if composefs_booted()?.is_some() {
composefs_rollback().await?
} else {
rollback(&opts).await?
}

#[cfg(not(feature = "composefs-backend"))]
rollback(&opts).await?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code pattern is the problem in a nutshell

  • It's duplicative and easy to mess up in later refactoring
  • As we move forward I think we should be thinking of composefs as the core/future and so we may want to actually start naming things ostree_ as a prefix instead of prefixing everything with composefs_
  • But really more generally we should operate in terms of methods
  • I want to move the composefs repo loading into mod storage

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed with all the points. This was best effort that didn't require any other huge overhaul

@cgwalters cgwalters merged commit bda61be into bootc-dev:composefs-backend Sep 9, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants